home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / killerpigs.swf / scripts / frame_9 / PlaceObject2_100_142 / CLIPACTIONRECORD onClipEvent(load).as
Encoding:
Text File  |  2007-03-13  |  1.8 KB  |  79 lines

  1. onClipEvent(load){
  2.    function update()
  3.    {
  4.       if(swooping)
  5.       {
  6.          if(first_time)
  7.          {
  8.             save_x = this._x;
  9.             save_y = this._y;
  10.             first_time = false;
  11.             dummy_x = 0;
  12.             dummy_y = 0;
  13.          }
  14.          dummy_x += _level0.dirn * _level0.step;
  15.          _level0.dummy._x = dummy_x;
  16.          if(count == 0)
  17.          {
  18.             if(50 < random(100))
  19.             {
  20.                direction = -1;
  21.             }
  22.             else
  23.             {
  24.                direction = 1;
  25.             }
  26.             limit = 10 + random(10);
  27.             count = 1;
  28.          }
  29.          else
  30.          {
  31.             count++;
  32.             if(limit < count)
  33.             {
  34.                count = 0;
  35.             }
  36.          }
  37.          this._x += 5 * direction;
  38.          this._y += 5;
  39.          if(350 < this._y)
  40.          {
  41.             swooping = false;
  42.             this._y = dummy_y + save_y;
  43.             this._x = dummy_x + save_x;
  44.             count = 0;
  45.             first_time = true;
  46.          }
  47.          temp_x = dummy_x + save_x;
  48.          if((450 < temp_x or temp_x < 10) and status == "ok")
  49.          {
  50.             trace("changed direction - with swooper !!");
  51.             _level0.change_dirn = true;
  52.             status = "change";
  53.          }
  54.          else
  55.          {
  56.             status = "ok";
  57.          }
  58.       }
  59.       else
  60.       {
  61.          this._x += _level0.dirn * _level0.step;
  62.          this.play();
  63.          if((450 < this._x or this._x < 10) and status == "ok")
  64.          {
  65.             _level0.change_dirn = true;
  66.             status = "change";
  67.          }
  68.          else
  69.          {
  70.             status = "ok";
  71.          }
  72.       }
  73.    }
  74.    status = "ok";
  75.    swooping = false;
  76.    count = 0;
  77.    first_time = true;
  78. }
  79.